<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/3.2.40/vue.global.js"></script>
</head>
<body>
    <div id="app">
        <div>{{name}}</div>
        <hello :a="name"/>
    </div>
    <template id="asd" >
        <div>
            <h1>{{msg}}{{a}}</h1>
        </div>
    </template>
</body>
</html>
<script>
    
    const app = Vue.createApp({
        data(){
            return{
                name:18,
            }
        },
        components:{
            'hello':
            {
                template:'#asd',
                // props:['a']//直接传入参数
                props:{
                    a:{
                        type:Number,
                        // required:true, 必定会有参数传过来，如若没有 便会警告 ，写了这个就可以不用写default
                        default(){
                            return {morenzhi:'默认值'}
                        }, 
                        validator:function(val){//给传入的数 做判断 若为真 则正确传入
                            return val % 2 == 0
                        }
                    }
                },
                data(){
                    return{
                        msg:'lilong'
                    }
                }
            }
        }
    })
    
    app.mount('#app')
</script>